#include<bits/stdc++.h>

#define int long long
#define maxn 100005

using namespace std;

inline int read(){
    int lre=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-'){
            f=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        lre=(lre<<3)+(lre<<1)+(c-'0');
        c=getchar();
    }
    return lre*f;
}

struct node{
    int v,a,d;
    //d:the beginning index
};

node make_node(int v,int a,int d){
    node lre;
    lre.v=v;
    lre.a=a;
    lre.d=d;
    return lre;
}

bool cmp(node a,node b){
    if(a.d==b.d){
        if(a.v==b.v){
            return a.a<b.a;
        }
        return a.v<b.v;
    }
    return a.d<b.d;
}

int n,m,L,V,res1,res2;
node arr[maxn];
int p[maxn];

int tot=0;
int l[maxn],r[maxn],ind[maxn];

int f(int dx,int v0,int a){
    int lre=v0*v0+2*a*dx;
    return lre;//return the vmax^2
}

int binar1(int beg,int x){
    int l=beg,r=m,mid,lre;
    while(l<=r){
        mid=l+r>>1;
        if(f(p[mid]-arr[x].d,arr[x].v,arr[x].a)>V*V){
            lre=mid;
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    return lre;
}//for a>0

int binar2(int beg,int x){
    int l=beg,r=m,mid,lre;
    while(l<=r){
        mid=l+r>>1;
        if(f(p[mid]-arr[x].d,arr[x].v,arr[x].a)>V*V){
            lre=mid;
            l=mid+1;
        }else{
            r=mid-1;
        }
    }
    return lre;
}//for a<0

bool cmp2(int a,int b){
    if(r[a]==r[b]){
        return l[a]<l[b];
    }
    return r[a]<r[b];
}

void solve(){
    res1=res2=tot=0;
    n=read();m=read();L=read();V=read();
    for(int i=1;i<=n;i++){
        arr[i].d=read();arr[i].v=read();arr[i].a=read();
    }
    sort(arr+1,arr+n+1,cmp);
    for(int i=1;i<=m;i++){
        p[i]=read();
    }
    sort(p+1,p+m+1);
    for(int i=1;i<=n;i++){
        if(arr[i].d>p[m])continue;
        int nxt=lower_bound(p+1,p+m+1,arr[i].d)-p;
        if(f(p[nxt]-arr[i].d,arr[i].v,arr[i].a)>V*V||\
           f(p[m]-arr[i].d,arr[i].v,arr[i].a)>V*V){
            res1++;
            //make range,add it
            if(arr[i].a>0){
                //find for min
                l[++tot]=binar1(nxt,i);r[tot]=m;
            }else if(arr[i].a<0){
                l[++tot]=nxt;r[tot]=binar2(nxt,i);
            }else{
                l[++tot]=nxt;r[tot]=m;
            }
            ind[tot]=tot;
//            cout<<"range ["<<l[tot]<<","<<r[tot]<<"]"
        }
    }
    printf("%lld ",res1);
    sort(ind+1,ind+tot+1,cmp2);
    int lst=0;//the latest index
    for(int i=1;i<=tot;i++){
        if(l[ind[i]]>lst){
            res2++;
            lst=r[ind[i]];
        }
    }
    printf("%lld\n",m-res2);
}

signed main(){

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    int t=read();
    while(t--){
        solve();
    }

    return 0;
}
